package net.sky.oa.service.shortmsg.impl;

import java.util.List;

import javax.annotation.Resource;

import net.sky.oa.dao.shortmsg.SmsInfoDao;
import net.sky.oa.model.SmsInfo;
import net.sky.oa.service.shortmsg.SmsInfoService;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.htsoft.core.service.impl.BaseServiceImpl;

@Service
@Transactional
public class SmsInfoServiceImpl extends BaseServiceImpl<SmsInfo>
	implements SmsInfoService{
	
	private SmsInfoDao smsInfoDao;

	public SmsInfoDao getSmsInfoDao() {
		return smsInfoDao;
	}

	@Resource
	public void setSmsInfoDao(SmsInfoDao smsInfoDao) {
		super.setDao(smsInfoDao);
		this.smsInfoDao = smsInfoDao;
	}

	public SmsInfo findByEmpId(long empId) throws Exception {
		
		List<SmsInfo> empList = smsInfoDao.findByHql("from SmsInfo where user.id = "+empId,null);
		if(null!=empList&&empList.size()>=1) {
			return empList.get(0);
		} else {
			return null;
		}
	}
	
	public List<SmsInfo> findByAccount(String account){
		return this.smsInfoDao.findByAccount(account);
	}
	
	public List<SmsInfo> findByPort(String port) throws Exception {
		return this.smsInfoDao.findByPort(port);
	}
	
}
